package ru.weather.common;

import org.junit.jupiter.api.Assertions;
import ru.weather.common.responseData.CorrectResponse;


import static org.junit.jupiter.api.Assertions.*;
import static ru.weather.common.Data.MapInit;

/**
 * Класс для заготовленных ассертов под тесты
 */
public class AssertUtils {

    public static void assertLocation(CorrectResponse correctResponse, String cityName) {

        Assertions.assertAll("Grouped assertions for city parametrs",
                () -> assertEquals(MapInit().get(cityName).get("name"), correctResponse.getLocation().getName(),"Name is wrong"),
                () -> assertEquals(MapInit().get(cityName).get("region"), correctResponse.getLocation().getRegion(),"region is wrong"),
                () -> assertEquals(MapInit().get(cityName).get("country"), correctResponse.getLocation().getCountry(),"country is wrong"),
                () -> assertEquals(MapInit().get(cityName).get("lat"), correctResponse.getLocation().getLat(),"lat is wrong"),
                () -> assertEquals(MapInit().get(cityName).get("lon"), correctResponse.getLocation().getLon(),"lon is wrong"),
                () -> assertEquals(MapInit().get(cityName).get("tz_id"), correctResponse.getLocation().getTzId(),"tz_id is wrong")
        );
    }
        public static void assertCurrent(CorrectResponse correctResponse) {
            Assertions.assertAll("Grouped assertions for current",
                    () -> assertNotNull(correctResponse.getCurrent().getWindDegree(), "wind degree must be"),
                    () -> assertTrue(correctResponse.getCurrent().getHumidity()>50, "humidity must be more than 50 (NO)"),
                    () -> assertTrue(correctResponse.getCurrent().getTempC() > -5 && correctResponse.getCurrent().getTempC() < 10, "temperature must be between -5 and 10"),
                    () -> assertTrue(correctResponse.getCurrent().getPressureMb()> 995 && correctResponse.getCurrent().getPressureMb() < 1005 , "pressure must always be 1000 (NO)")

            );
        }

}
